package com.threez.core.utils;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;

/**
 * @author zhaozz
 * @title EnvUtil
 * @date 2023/1/14 13:18
 */
@AutoConfiguration(before = JacksonAutoConfiguration.class)
public class EnvUtil {
    /**
     * 环境名称
     */
    public static String env;
    /**
     * 服务模块名
     */
    public static String applicationName;

    public static String getEnv() {
        return env;
    }

    @Value("${spring.profiles.active}")
    public void setEnv(String env) {
        System.out.println("-------------------------" + env);
        EnvUtil.env = env.replaceAll("-", "_");
    }

    public static String getApplicationName() {
        return applicationName;
    }

    @Value("${spring.application.name}")
    public void setApplicationName(String moduleName) {
        EnvUtil.applicationName = moduleName.replaceAll("-", "_");
    }
}
